package org.itboys.core.controller.front.small;

import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.itboys.core.dto.gift.SundayGiftDto;
import org.itboys.core.service.mongo.front.SundayFrontGiftService;
import org.itboys.core.util.ResponseMessage;
import org.itboys.framework.spring.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 作者：zzq
 * 时间：2018/10/26
 * 描述：礼物
 */
@Controller
@RequestMapping("/sunday/small/gift")
@Api(value = "gift", description = "礼物")
public class SundaySmallGiftController extends BaseController {
    @Autowired
    private SundayFrontGiftService giftService;
    @RequestMapping(value = "/select", method = {RequestMethod.POST})
    @ApiOperation(value = "查询列表")
    public void select(
            HttpServletRequest request,
            HttpServletResponse response,
            @ApiParam(value = "用户Id") @RequestParam(value = "memberId", required = true) Long memberId,
                @ApiParam(value = "状态 0未兑换 1已兑换") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(value = "查询类型 1 送出 2 收到") @RequestParam(value = "searchType", required = true) Integer searchType
    ) {
        List<SundayGiftDto> result = giftService.select(memberId, status, searchType);
        ResponseMessage.success(result);
    }


    @RequestMapping(value = "/findOne", method = RequestMethod.POST)
    @ApiOperation(value = "查询礼物详情")
    public void findOne(
            HttpServletRequest request,
            HttpServletResponse response,
            @ApiParam(value = "礼物ID") @RequestParam(value = "giftId", required = true) Long giftId
    ) {
        SundayGiftDto result = giftService.findOne(giftId);
        ResponseMessage.success(result);
    }


}
